﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AutoCooker1
{
    /// <summary>
    /// Problem: 
    ///     tight coupling, 
    ///     break single responsibility principle
    ///     
    /// 解决方案 use interface
    ///             (see AutoCooker2)
    /// </summary>
    class AutoCooker1
    {        
        private Person _person;

        public AutoCooker1(Person ps)
        {
            _person = ps;
        }

        public void DoCook()
        {
            Console.WriteLine("AutoCooker start to cook");
            // notify person 
            if (_person != null) 
                _person.CookStartedReply();

            Console.WriteLine("AutoCooker is cooking");
            // notify person
            if (_person != null) 
                _person.CookProgressingReply();

            Console.WriteLine("AutoCooker finish to Cook");
            // notify person
            if (_person != null)
            {
                int grade = _person.CookCompletedReply();
                Console.WriteLine("My appetite is {0} %",grade);
            }
        }
    }
}
